body {
  margin: 0;
  padding: 0;
  border:0;
  width: 100%;
  height: 100%;
  /* 移除固定高度 */
  /* overflow: hidden; */ /* 移除或注释掉 */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  /* height: 100vh; */ /* 移除或注释掉 */
  overflow-x: hidden; /* 只限制水平方向溢出 */
}
#app {
  width: 100vw;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column; /* 改为列方向，允许内容垂直排列 */
  min-height: 100vh; /* 保持最小高度占满视口 */
  /* overflow-x: hidden; */ /* 可以移除，让 html, body 处理 */
}
.app-container {
  display: flex;
  height: 100vh; /* 保持高度占满视口 */
  /* width: 100%; */ /* 移除或注释掉 */
  flex-grow: 1; /* 让 app-container 填充剩余空间 */
  overflow-y: hidden;
  max-width: none;
  background-color: #f7f7f8;
}

/* 侧边栏样式 */
.sidebar {
  width: 260px;
  min-width: 260px;
  background-color: #ffffff;
  border-right: 1px solid #ffffff;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky; /* 尝试使用 sticky 定位 */
  top: 0; /* 配合 sticky */
  height: 100vh; /* 仍然需要高度来撑开 sticky 容器 */
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  overflow-y: hidden; /* 防止整个侧边栏滚动 */
}

/* 确保侧边栏内容可以布局合理 */
.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 添加侧边栏用户信息样式 */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 1rem;
}
.username {
  font-weight: 600;
  font-size: 1rem;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 侧边栏折叠状态 */
.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
  padding: 1rem 0.5rem;
}

/* 侧边栏折叠时隐藏文字内容 */
.sidebar.collapsed .sidebar-content {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
}

/* 侧边栏折叠时保持按钮可见 */
.sidebar.collapsed .toggle-sidebar-btn {
  left: 18px; /* 在折叠状态下居中放置 */
  top: 20px;
}

/* 侧边栏切换按钮 */
.toggle-sidebar-btn {
  position: absolute;
  left: 220px; /* 放在侧边栏内部靠右侧 */
  top: 20px;
  width: 24px;
  height: 24px;
  background-color: #2563eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 15;
  transition: all 0.3s ease;
}

.toggle-sidebar-btn:hover {
  background-color: #1d4ed8;
}

/* 添加旋转效果 */
.sidebar.collapsed .toggle-sidebar-btn i {
  transform: rotate(180deg);
}

/* 移动端不显示折叠按钮 */
@media (max-width: 768px) {
  .toggle-sidebar-btn {
    display: none;
  }
}

/* 当侧边栏折叠时，调整按钮位置 */
@media (min-width: 769px) {
  .sidebar.collapsed .toggle-sidebar-btn {
    left: 18px; /* 在折叠状态下居中放置 */
  }
}

/* 修复历史对话列表滚动问题 */
.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: calc(100vh - 240px); /* 设置最大高度，减去其他侧边栏元素的高度 */
  overflow-y: auto; /* 启用垂直滚动 */
  padding-right: 4px; /* 为滚动条留出空间 */
  margin-bottom: 1rem;
}

/* 美化滚动条样式 */
.conversations-list::-webkit-scrollbar {
  width: 4px;
}

.conversations-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.conversations-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.conversations-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* 移动端侧边栏样式增强 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px; /* 完全隐藏 */
    top: 0;
    bottom: 0;
    transition: left 0.3s ease-in-out;
    width: 260px;
    min-width: 260px;
    padding: 1rem;
  }

  .sidebar.mobile-open {
    left: 0;
  }
  
  /* 移动端按钮位置调整 */
  .mobile-menu-btn {
    position: relative; /* 改为相对定位 */
    z-index: 5;
    top: 10px;
    left: 10px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px; /* 稍微调小按钮 */
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3); /* 增加阴影效果 */
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-menu-btn:hover,
  .mobile-menu-btn:active {
    background-color: #1d4ed8;
    transform: translateY(-1px); /* 悬停时微微上浮 */
  }
  
  /* 侧边栏打开时的遮罩层 */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 5;
  }
  
  .sidebar.mobile-open + .sidebar-backdrop {
    display: block;
  }
}

/* 主内容区自适应 */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

/* 当侧边栏折叠时，主内容区拓宽 */
.sidebar.collapsed + .main-wrapper {
  margin-left: 60px;
}

.sidebar-header {
  padding: 1rem 0;
  text-align: center;
  border-bottom: 1px solid #e6e6e6;
  flex-shrink: 0; /* 防止这些元素被压缩 */
}

.sidebar-header h2 {
  margin: 0;
  color: #333;
  font-size: 1.25rem;
  font-weight: 600;
}

.new-chat-btn {
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  padding: 0.8rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-weight: 500;
  flex-shrink: 0; /* 防止这些元素被压缩 */
}

.new-chat-btn:hover {
  background-color: #1d4ed8;
}

.model-selector {
  padding: 1rem 0;
  border-top: 1px solid #e6e6e6;
  margin-top: auto; /* 将其推至底部 */
  flex-shrink: 0;
}

.model-selector label {
  display: block;
  margin-bottom: 0.5rem;
  color: #666;
  font-size: 0.9rem;
}

.model-select {
  width: 100%;
}

/* 页面标题栏样式 - 降低高度并添加透明渐变 */
.page-header {
  width: 100%;
  background-image: linear-gradient(to bottom, #ffffff, rgba(255,255,255,0.85)); /* 下半部分改为半透明 */
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 0.8rem 1.5rem; /* 减小垂直内边距使标题栏变矮 */
  box-shadow: 0 1px 8px rgba(0,0,0,0.04); /* 减轻阴影效果 */
  position: sticky;
  top: 0;
  z-index: 5;
}

/* 修改标题栏布局 - 降低高度 */
.header-content {
  display: flex;
  align-items: center;
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 1.8rem; /* 减小高度 */
}

/* 调整标题样式 - 缩小字体 */
.site-title {
  font-size: 1.1rem; /* 缩小字体 */
  font-weight: 600;
  color: #222;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  text-align: center;
  letter-spacing: -0.01em;
  /* 使用带透明度的文字阴影 */
  text-shadow: 0 1px 0 rgba(255,255,255,0.7);
}

/* 移动端标题栏适配 */
@media (max-width: 768px) {
  .page-header {
    padding: 0.7rem 0.5rem; /* 进一步减小移动端高度 */
  }
  
  .header-content {
    padding: 0 0.5rem;
    height: 1.6rem; /* 减小移动端高度 */
  }
  
  .site-title {
    font-size: 0.95rem; /* 移动端进一步缩小字体 */
    max-width: 70%;
  }
}

/* 调整主内容区域以适应标题栏 */
.main-content {
  display: flex;
  flex-direction: column;
  /* height: 100vh; */ /* 移除或注释掉 */
  /* overflow: hidden; */ /* 移除或注释掉 */
  overflow: hidden;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* 侧边栏底部样式 */
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}
